//
//  commentViewController.m
//  评论
//
//  Created by dllo on 15/7/11.
//  Copyright (c) 2015年 蓝欧科技. All rights reserved.
//


#import "BaseHeader.h"
#import "commentViewController.h"
#import "titleView.h"
#import "AFNetworkHandler.h"
#import "LSYFastLookHotCommentsModel.h"
#import "LSYhotCommentsView.h"
#import "LSYnewCommentsView.h"

@interface commentViewController ()<UIScrollViewDelegate>
@property (nonatomic, retain) UIScrollView *scro;
@property (nonatomic, assign) NSInteger count;
@property (nonatomic, retain) titleView *titleV;
@property (nonatomic, assign) NSInteger HotCount;

@end

@implementation commentViewController

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [_ID release];
    [_titleV release];
    [_scro release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];

    [self createNaviBar];
    [self createScroView];
    [self createTableView];
    //    [self createCommentField];
    
    
}

#pragma mark - 页面布局
/**
 *  导航栏设置
 */
- (void)createNaviBar
{
    self.navigationController.navigationBar.translucent = NO;
    self.titleV = [titleView titleViewWithFrame:CGRectMake(0, 0, 200 * SCREEN_WIDTH / 375, 30 * SCREEN_HEIGHT / 667)];
    self.navigationItem.titleView = self.titleV;
}

/**
 *  创建ScroView 滑动效果
 */
- (void)createScroView
{
    self.scro.contentSize = CGSizeMake(SCREEN_WIDTH * 2, 0);
    self.scro.pagingEnabled = YES;
    self.scro.delegate = self;
    [self.view addSubview:self.scro];
    self.titleV.scro = self.scro;
}

/**
 *  创建评论列表你TableView
 */
- (void)createTableView
{
    /**
     最新评论
     */
    LSYnewCommentsView *newTableView = [LSYnewCommentsView newcommentsWithinitFrame:CGRectMake(0, 0, self.scro.frame.size.width, self.scro.frame.size.height) URL:self.ID.stringValue];
    [self.scro addSubview:newTableView];
    
    /**
     最热评论
     */
    LSYhotCommentsView *hotTableView = [LSYhotCommentsView hotcommentsWithinitFrame:CGRectMake(self.scro.frame.size.width, 0, self.scro.frame.size.width, self.scro.frame.size.height) hotURL:self.ID.stringValue];
    [self.scro addSubview:hotTableView];
}

/**
 *  底部评论输入框
 */
- (void)createCommentField
{
    UIView *commentView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - 50 * SCREEN_HEIGHT / 667 - 64, SCREEN_WIDTH, 50 * SCREEN_HEIGHT / 667)];
    UIView *commentView = [[[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - 50 * SCREEN_HEIGHT / 667 - 64, SCREEN_WIDTH, 50 * SCREEN_HEIGHT / 667)] autorelease];
    commentView.backgroundColor = [UIColor colorWithRed:40 / 225.0 green:239 / 225.0 blue:255 / 225.0 alpha:1];
    [self.view addSubview:commentView];
    UITextField *field = [[UITextField alloc] initWithFrame:CGRectMake(10 * SCREEN_WIDTH / 667, 10 * SCREEN_HEIGHT / 667, 200 * SCREEN_WIDTH / 375, 30 * SCREEN_HEIGHT / 667)];
    UITextField *field = [[[UITextField alloc] initWithFrame:CGRectMake(10 * SCREEN_WIDTH / 667, 10 * SCREEN_HEIGHT / 667, 200 * SCREEN_WIDTH / 375, 30 * SCREEN_HEIGHT / 667)] autorelease];
    field.backgroundColor = [UIColor whiteColor];
    [commentView addSubview:field];
}


#pragma mark - scroView 协议方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    self.count = self.scro.contentOffset.x / SCREEN_WIDTH;
    id result = [NSString stringWithFormat:@"%ld", self.count];
    
//通知中心传值 传两个参数 1.偏移量处理后的数据 2.当前页面的scroView
    [[NSNotificationCenter defaultCenter] postNotificationName:@"count" object:result];
    
   
}


- (void)viewWillAppear:(BOOL)animated
{
    NSLog(@"评论");
    self.navigationController.navigationBar.Hidden = NO;
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
